# rocksdb.cmake
# 本文件包含着从外部导入 RocksDB 所需要的信息

INCLUDE(ExternalProject)

set(ROCKSDB_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/rocksdb)
set(ROCKSDB_GIT_URL      https://atomgit.com/dangaldb/RocksDB-Mirror.git)  # 指定git仓库地址
set(ROCKSDB_CONFIGURE    cd ${ROCKSDB_ROOT}/src/extern_rocksdb)
set(ROCKSDB_MAKE         cd ${ROCKSDB_ROOT}/src/extern_rocksdb && make static_lib)
set(ROCKSDB_INSTALL      cd ${ROCKSDB_ROOT}/src/extern_rocksdb && make install PREFIX=${ROCKSDB_ROOT}/output) 

ExternalProject_Add(extern_rocksdb
        PREFIX            ${ROCKSDB_ROOT}
        GIT_REPOSITORY    ${ROCKSDB_GIT_URL}
        CONFIGURE_COMMAND ${ROCKSDB_CONFIGURE}
        BUILD_COMMAND     ${ROCKSDB_MAKE}
        INSTALL_COMMAND   ${ROCKSDB_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${ROCKSDB_ROOT}/output
        -DBUILD_SHARED_LIBS=OFF
)

INCLUDE_DIRECTORIES(${ROCKSDB_ROOT}/output/include)
LINK_DIRECTORIES(${ROCKSDB_ROOT}/output/lib)